package com.ruoyi.web.controller.reserve;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;

import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.reserve.domain.Checkitem;
import com.ruoyi.reserve.domain.Order;
import com.ruoyi.reserve.domain.OrderSetting;
import com.ruoyi.reserve.service.impl.IOrderSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

import static com.ruoyi.common.utils.PageUtils.startPage;

@RestController
@RequestMapping("/reserve/orderSetting")
public class OrderSettingController extends BaseController {

    @Autowired
    private IOrderSettingService orderSettingService;

    /**
     * 通过日期查询当天的预约上限与已预约人数
     */
    @GetMapping(value = "/{orderDate}")
    public AjaxResult getInfoByorderDate (@PathVariable String orderDate) {
        return AjaxResult.success(orderSettingService.selectOrderSetting(orderDate));
        // return AjaxResult.success(orderSettingService.selectOrderSetting(orderDate));
    }


    /**
     * 获取全部预约设置
     */
    @GetMapping("/list")
    public List<OrderSetting> list(OrderSetting orderSetting)
    {

        List<OrderSetting> list = orderSettingService.selectOrderSettingList(orderSetting);
        return orderSettingService.selectOrderSettingList(orderSetting);
    }


    /**
     * 更新
     */
    @Log(title = "预约设置管理", businessType = BusinessType.UPDATE)
    @PostMapping("/updateOrderSetting")
    public AjaxResult updateOrderSetting(@RequestBody OrderSetting orderSetting)
    {

        return toAjax(orderSettingService.updateOrderSetting(orderSetting));
    }

    /**
     * 新增预约设置
     */
    @Log(title = "预约设置管理", businessType = BusinessType.INSERT)
    @PostMapping("/addOrderSetting")
    public AjaxResult addOrderSetting(@RequestBody OrderSetting orderSetting)
    {
        return toAjax(orderSettingService.insertOrderSetting(orderSetting));
    }
}
